{include file="./public/footer" /}
{include file="./public/menu" /}
<!--引入kindeditor编辑器-->
<script src="__STATIC__/Admin/kindeditor/kindeditor-all.js"></script>
<!--/sidebar-->
<div class="main-wrap">

    <div class="crumb-wrap">
        <div class="crumb-list"><i class="icon-font"></i><a href="/admin.php">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="/admin.php/ware/lists">线路管理</a><span class="crumb-step">&gt;</span><span>新增线路</span></div>
    </div>
    <div class="result-wrap">
        <div class="result-content">
            <form  id="andy_form"  name="myform" enctype="multipart/form-data">
                <table class="insert-tab" width="100%">
                    <tbody><tr>
                        <th width="120"><i class="require-red">*</i>商品分类：</th>
                        <td>
                            <select name="ware_type_id" id="type_id" class="required" onchange="getWareType(this)">
                                <option value="">请选择</option>
                                {volist name="wareType" id="wt"}
                                    <option value="{$wt.type_id}">{$wt.type_name}</option>
                                {/volist}
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th width="120"><i class="require-red">*</i>分类：</th>
                        <td>
                            <select name="class_id" id="class_id" class="required">
                                <option value="">请选择</option>
                                <option value="3">手机卡</option>
                                <option value="4">当地特产</option>
                                <option value="5">潜水考证</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require-red">*</i>商品名称：</th>
                        <td>
                            <input class="common-text required"  name="title" size="50"  type="text">
                        </td>
                    </tr>
                    <tr>
                        <th>商品描述：</th>
                        <td>
                            <input class="common-text required"  name="remarks" size="50"  type="text">
                        </td>
                    </tr>
                    <!--<tr>-->
                        <!--<th>商品属性</th>-->
                        <!--<td>-->
                            <!--{volist name="config" id="c"}-->
                                <!--<input type="checkbox" onclick="check(this)" name="config" value="{$c.id}">&nbsp;{$c.title}&nbsp;-->
                            <!--{/volist}-->
                        <!--</td>-->
                    <!--</tr>-->
                    <tr >
                        <th><i class="require-red">*</i>商品价格：</th>
                        <td><input class="common-text" name="price" size="50"  type="text"></td>
                    </tr>
                    <tr id="wareCollagePrice" style="display: none;">
                        <th><i class="require-red">*</i>商品团购价：</th>
                        <td><input class="common-text" name="collage_price" size="50"  type="text"></td>
                    </tr>
                    <tr id="wareCollagePeople" style="display: none;">
                        <th><i class="require-red">*</i>团购人数：</th>
                        <td><input class="common-text" name="collage_people" size="50"  type="text"></td>
                    </tr>
                    <tr id="wareCollageTime" style="display: none;">
                        <th><i class="require-red">*</i>团购时间：</th>
                        <td><input class="common-text" name="collage_time" size="50"  type="text"></td>
                    </tr>
                    <tr id="wareSeckillPrice" style="display: none;">
                        <th><i class="require-red">*</i>商品秒杀价：</th>
                        <td><input class="common-text" name="seckill_price" size="50"  type="text"></td>
                    </tr>
                    <tr id="startTime" style="display: none;">
                        <th><i class="require-red">*</i>开始时间：</th>
                        <td><!--<input class="common-text" name="seckill_start_time" size="50"  type="text">-->
						<input type="text" class="common-text"  onclick="fPopCalendar(event,this,this)" readonly="readonly" name="seckill_start_time" >
						</td>
                    </tr>
                    <tr id="endTime" style="display: none;">
                        <th><i class="require-red">*</i>结束时间：</th>
                        <td><!--<input class="common-text" name="seckill_end_time" size="50"  type="text">-->
						<input type="text" class="common-text"  onclick="fPopCalendar(event,this,this)" readonly="readonly" name="seckill_end_time" >
						</td>
						</td>
                    </tr>
                    <tr id="seckillNum" style="display: none;">
                        <th><i class="require-red">*</i>秒杀总数量：</th>
                        <td><input class="common-text" name="seckill_num" size="50"  type="text"></td>
                    </tr>
                    <!--<tr>-->
                        <!--<th><i class="require-red">*</i>出发城市：</th>-->
                        <!--<td>-->
                            <!--<input class="common-text required"  name="city" size="50"  type="text">-->
                        <!--</td>-->
                    <!--</tr>-->
                    <tr>
                        <th>封面图</th>
                        <td>
                            <input id="file_upload"  type="file" multiple="true" >
                            <img style="display: none" id="upload_org_code_img" src="" width="150" height="150">
                            <input id="file_upload_image" name="cover" type="hidden" multiple="true" value="">
                        </td>
                    </tr>
                    <tr>
                        <th>缩略图</th>
                        <td>
                            <button id="thumb"></button>
                            <div id="thumbBox"></div>
                        </td>
                    </tr>

                    <tr>
                        <th>商品详情：</th>
                        <td><textarea name="trip" class="common-textarea" id="kindeditor_id" cols="30" style="width: 98%;" rows="10"></textarea></td>
                    </tr>

                    <tr>
                        <th><i class="require-red">*</i>商品状态：</th>
                        <td>
                            &nbsp;<input type="radio"  value="1" size="85" name="status" class="common-text" checked>正常&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;<input type="radio" value="0" name="status" size="85" class="commont-text">代审
                        </td>
                    </tr>


                    <tr>
                        <th></th>
                        <td>
                            <input class="btn btn-primary btn6 mr10" id="andy_line_submit" value="提交" type="button">
                            <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                        </td>
                    </tr>
                    </tbody></table>
            </form>
        </div>
    </div>

</div>
<!--/main-->
<script>
    KindEditor.ready(function(K) {
        window.editor = K.create('#kindeditor_id',{
            uploadJson : '/admin.php/image/kindUpload',
            afterBlur: function(){this.sync();}
        });
    });

    var SCOPE = {
        'save_url' : '/admin.php/ware/add',
        'jump_url' : '/admin.php/ware/lists',
        'ajax_upload_swf' : "__STATIC__/Admin/uploadify/uploadify.swf",
        'ajax_upload_image_url' : '/admin.php/image/ajaxUploadImage',
    }

    //商品分类方法
    function getWareType(obj){
        var value = $(obj).val();
        if(value == 2){
            $('#wareSeckillPrice').show();
            $("#seckillNum").show();
            $("#startTime").show();
            $("#endTime").show();
        }else if(value == 3){
            $("#wareCollagePrice").show();
            $("#wareCollagePeople").show();
            $("#wareCollageTime").show();
            $("#wareSeckillPrice").hide();
            $("#seckillNum").hide();
            $("#startTime").hide();
            $("#endTime").hide();
        }else{
            $("#wareCollagePrice").hide();
            $("#wareCollagePeople").hide();
            $("#wareSeckillPrice").hide();
            $("#seckillNum").hide();
            $("#startTime").hide();
            $("#endTime").hide();
            $("#wareCollageTime").hide();
        }

    }

    //商品属性
    function check(obj){
        if($(obj).attr('checked')){
            $(obj).attr('checked',false);
        }else{
            $(obj).attr('checked',true);
        }

    }
</script>
<script>
    //图片上传
    $(function(){
        $('#thumb').uploadify({
            buttonClass : 'bgred',
            buttonText : '上传图片',
            height : 30,
            fileTypeDesc : 'Image Files',
            fileObjName : 'file',
            //允许上传的图片后缀
            fileTypeExts : '*.gif;*.jpg;*.png;*.jpeg',
            swf : "__STATIC__/Admin/uploadify/uploadify.swf",
            uploader : "{:url('ware/ajaxUploadImage',['tpl'=>'thumb'])}",
            width :120,
            onUploadSuccess : function(file,data,response){

                $("#thumbBox").append(data);
            }
        })
    })

    //添加
    $("#andy_line_submit").click(function(){
        //获取商品属性
        var config = [];
        $('input[name="config"]:checked').each(function(){ //遍历，将所有选中的值放到数组中
            config.push($(this).val());
        });
        //获取轮播图
        obj = $('input[name="img"]');
        var img = [];
        for(var i = 0; i < obj.length; i++){
            img.push(obj[i].value);
        }
        //获取剩余的信息
        var data = $("#andy_form").serializeArray();
        var postData = {};
        $(data).each(function(){
            postData[this.name] = this.value;
        });
        //赋值
        postData.config = config;
        postData.img = img;

        //获取提交地址
        var url = SCOPE.save_url;
        //获取返回地址
        var jump_url = SCOPE.jump_url;
        $.post(url,postData,function(result){
            if(result.status == 1) {
                //成功
                return dialog.success(result.message,jump_url);
            }else if(result.status == 0) {
                // 失败
                return dialog.error(result.message);
            }
        },'JSON');
    });
</script>
{include file="./public/bottom" /}